package org.example

import org.apache.spark.sql.SparkSession

object sly {
  def main(args: Array[String]): Unit = {
    val spark=SparkSession
      .builder
      .master("local[*]")
      .appName("spark")
      .getOrCreate()
    val sc =spark.sparkContext
    val first_half =sc.textFile("E:\\gfl08/Employee_salary_first_half.csv")
    val drop_first=first_half.mapPartitionsWithIndex((ix,it)=>{
      if (ix==0) it.drop(1)
      it
    })
    val split_fist=drop_first.map(line=>{val data=line.split(",");
    (data(1),data(6).toLongOption)})

    val sort_first=split_fist.sortBy(x=>x._2,false)
    sort_first.take(3).foreach(System.out.println)
    spark.stop()
  }
}
